<?php
/***************
* @Project	Warabi
* @Author	Feifei
* @Date		04/20/2009
***************/

/**This module is to deal the ap resend card request**/
include_once($_SERVER['DOCUMENT_ROOT'].'/header.inc.php');

$httprequest = new wbHttpRequest();

list($headers , $body) = $httprequest->output();

$sender_name = rawurldecode($_GET["sender"]);

/***if the sender name is empty or receiver_name and card id is empty**/
if(empty($sender_name)){
	header(error_url_param_missing);
	exit;
}

/** wsse authorize **/
/***if the wsse is wrong , give a 401 unauthorized response**/
$db = new wbDatabase();
$xwsse = $headers["X_WSSE"];
$type=0;
$doorkey = magicWsse($xwsse , $db , $type);

if(!$doorkey){
	header(error_autorized_header);
	exit;
}


$xml = simplexml_load_string($body);
if(!$xml){
	header(error_xml_structure);
	exit;
}

$cardid=array();
$invites = $xml->invite;
foreach($invites as $iv){
	$cardid[] = intval($iv->id);
}
$wherearr = array();
foreach($cardid as $ci){
	$wherearr[] = " cardListId = ".$ci;
}
$where = implode(" or " , $wherearr);
$sql = "update ".__table_card_list__." set sendDate=now() , deleteFlag=0 where ".$where;
$err = $db->query($sql);

if(!$err){
	header(error_server_system);
	exit;
}

header(success_response);


?>